<div class="content-section introduction">
    <div>
        <span class="feature-title">InputMask</span>
        <span>InputMask component is used to enter input in a certain format such as numeric, date, currency, email and phone.</span>
    </div>
</div>

<div class="content-section implementation">

    <div class="ui-g ui-fluid">
        <div class="ui-g-12 ui-md-6 ui-lg-4">
            <span>Basic</span>
            <p-inputMask mask="99-999999" [(ngModel)]="val1" placeholder="99-999999"></p-inputMask>
        </div>
        
        <div class="ui-g-12 ui-md-6 ui-lg-4">
            <span>SSN</span>
            <p-inputMask mask="999-99-9999" [(ngModel)]="val2" placeholder="999-99-9999"></p-inputMask>
        </div>
        
        <div class="ui-g-12 ui-md-6 ui-lg-4">
            <span>Date</span>
            <p-inputMask mask="99/99/9999" [(ngModel)]="val3" placeholder="99/99/9999" slotChar="mm/dd/yyyy"></p-inputMask>
        </div>
        
        <div class="ui-g-12 ui-md-6 ui-lg-4">
            <span>Phone</span>
            <p-inputMask mask="(999) 999-9999" [(ngModel)]="val4" placeholder="(999) 999-9999"></p-inputMask>
        </div>
        
        <div class="ui-g-12 ui-md-6 ui-lg-4">
            <span>Phone Ext</span>
            <p-inputMask mask="(999) 999-9999? x99999" [(ngModel)]="val5" placeholder="(999) 999-9999? x99999"></p-inputMask>
        </div>
        
        <div class="ui-g-12 ui-md-6 ui-lg-4">
            <span>Serial Number</span>
            <p-inputMask mask="a*-999-a999" [(ngModel)]="val6" placeholder="a*-999-a999"></p-inputMask>
        </div>
    </div>
    
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;InputMaskModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>Component is defined using p-inputMask element with a mask and two-way value binding is enabled with standard ngModel directive.</p>   
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputMask [(ngModel)]="val" mask="99-9999"&gt;&lt;/p-inputMask&gt;
</code>
</pre>

            <h3>Mask</h3>
            <p>Mask format can be a combination of the the following built-in definitions.</p>
            <ul>
                <li>a - Alpha character (A-Z,a-z)</li>
                <li>9 - Numeric character (0-9)</li>
                <li>* - Alpha numberic character (A-Z,a-z,0-9)</li>
            </ul>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputMask [(ngModel)]="val" mask="a*-999-a999"&gt;&lt;/p-inputMask&gt;
</code>
</pre>
            
            <h3>SlotChar</h3>
            <p>Underscore is the default placeholder for a mask and this can be customized using slotChart option.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputMask [(ngModel)]="val" mask="99-9999" slotChar=" "&gt;&lt;/p-inputMask&gt;
</code>
</pre>
            
            <h3>Optional Values</h3>
            <p>If the input does not complete the mask definition, it is cleared by default. Use autoClear property to control this behavior. In addition,
            certain part of a mask can be made optional by using ? symbol where anything after the question mark becomes optional.</p>
                        
            <h3>Model Driven Forms</h3>
            <p>InputMask can be used in a model driven form as well.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-inputMask formControlName="username" mask="(999) 999-9999? x99999"&gt;&lt;/p-inputMask&gt;
</code>
</pre>

            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>type</td>
                            <td>string</td>
                            <td>text</td>
                            <td>HTML5 input type</td>
                        </tr>
                        <tr>
                            <td>mask</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Mask pattern.</td>
                        </tr>
                        <tr>
                            <td>slotChar</td>
                            <td>string</td>
                            <td>_</td>
                            <td>Placeholder character in mask, default is underscore.</td>
                        </tr>
                        <tr>
                            <td>autoClear</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Clears the incomplete value on blur.</td>
                        </tr>
                        <tr>
                            <td>unmask</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Defines if ngModel sets the raw unmasked value to bound value or the formatted mask value.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the input field.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the input field.</td>
                        </tr>
                        <tr>
                            <td>placeholder</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Advisory information to display on input.</td>
                        </tr>
                        <tr>
                            <td>size</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Size of the input field.</td>
                        </tr>
                        <tr>
                            <td>maxlength</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Maximum number of character allows in the input field.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Specifies tab order of the element.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element value cannot be altered.</td>
                        </tr>
                        <tr>
                            <td>readonly</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that an input field is read-only.</td>
                        </tr>
                        <tr>
                            <td>name</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the input field.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the component.</td>
                        </tr>
                        <tr>
                            <td>required</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that an input field must be filled out before submitting the form.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <h3>Events</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onFocus</td>
                            <td>event: Browser event</td>
                            <td>Callback to invoke when input receives focus.</td>
                        </tr> 
                        <tr>
                            <td>onBlur</td>
                            <td>event: Browser event</td>
                            <td>Callback to invoke when input loses focus.</td>
                        </tr>   
                        <tr>
                            <td>onComplete</td>
                            <td>-</td>
                            <td>Callback to invoke on when user completes the mask pattern.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Styling</h3>
            <p>Styling is same as <a href="#" [routerLink]="['/inputtext']">inputtext component</a>, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/inputmask" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;div class="ui-g ui-fluid"&gt;
    &lt;div class="ui-g-12 ui-md-6 ui-lg-4"&gt;
        &lt;span&gt;Basic&lt;/span&gt;
        &lt;p-inputMask mask="99-999999" [(ngModel)]="val1" placeholder="99-999999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="ui-g-12 ui-md-6 ui-lg-4"&gt;
        &lt;span&gt;SSN&lt;/span&gt;
        &lt;p-inputMask mask="999-99-9999" [(ngModel)]="val2" placeholder="999-99-9999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="ui-g-12 ui-md-6 ui-lg-4"&gt;
        &lt;span&gt;Date&lt;/span&gt;
        &lt;p-inputMask mask="99/99/9999" [(ngModel)]="val3" placeholder="99/99/9999" slotChar="mm/dd/yyyy"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="ui-g-12 ui-md-6 ui-lg-4"&gt;
        &lt;span&gt;Phone&lt;/span&gt;
        &lt;p-inputMask mask="(999) 999-9999" [(ngModel)]="val4" placeholder="(999) 999-9999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="ui-g-12 ui-md-6 ui-lg-4"&gt;
        &lt;span&gt;Phone Ext&lt;/span&gt;
        &lt;p-inputMask mask="(999) 999-9999? x99999" [(ngModel)]="val5" placeholder="(999) 999-9999? x99999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
    
    &lt;div class="ui-g-12 ui-md-6 ui-lg-4"&gt;
        &lt;span&gt;Serial Number&lt;/span&gt;
        &lt;p-inputMask mask="a*-999-a999" [(ngModel)]="val6" placeholder="a*-999-a999"&gt;&lt;/p-inputMask&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class InputMaskDemo &#123;

    val1: string;

    val2: string;

    val3: string;

    val4: string;

    val5: string;
    
    val6: string;
    
&#125;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>